import React, { Component } from 'react';
import Perf from 'react-addons-perf';
import { subscribeInmsec } from '../lib/socket';
import Module1 from './components/module1';
import './index.css';
window.Perf = Perf
class List extends Component {
  constructor(props) {
    super(props);
    this.state = {
      num: 1,
      array: []
    }
  }
  componentWillMount() {

    subscribeInmsec((err, array) => {
      this.setState({
        array: array
      })
    });
  }
  // addNum(num) {
  //   this.setState({
  //     num: num + 1
  //   })
  // }

  render() {
    const { array } = this.state;

    return (
      <div className="List">
        {/* <button onClick={this.addNum.bind(this)} >点击添加1</button> */}
        <div className="content">
          {
            array.map((item, index) => (
              <div key={index} className="component">
                本组数据：{item.value.substr(0, 9)}
                <Module1 value={item.value.substr(0, 9)} />
              </div>
            ))
          }
        </div>
      </div>
    );
  }
}

export default List;
